<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE HTML>
<html lang="en">
<head>
<base href="<%=basePath%>">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/css/bootstrap.min.css">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/css/main.css">
<script src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
<script src="${pageContext.request.contextPath}/js/main.js"></script>
<title>总部</title>
<style>
.main_div {
	min-width: 1000px;
}

.pageChange {
	float: right;
	color: #337ab7;
}

.pageChange>span {
	cursor: pointer
}

.pageChange>span:hover {
	color: blue
}
</style>
</head>
<body>
	<%@ include file="header.jsp"%>
	<%@ include file="left.jsp"%>
	<div id="index"
		style="position: absolute;left: 180px;top: 80px;bottom: 0;right: 0;">
		<section id="main">
			<div class="scrollbar1-1" id="style1-1">
				<div class="main_div" style="height:40px">
					<div class="main_title">
						<span>直营审核</span>
					</div>

					<form class="form-inline" id="detailForm" action="" method="post"
						style="margin-top: 30px;margin-left: 20px">
						<input style="display:none" value="7" id="pageCount"
							name="pageCount" />
						<div class="form-group">
							<label for="orderCode">商品名称:</label> <input type="text"
								name="productName" class="form-control" id="productNames"
								placeholder="">
						</div>
						<div class="form-group">
							<label>审核状态:</label> <select class="form-control" id="chakaVal">
								<option value="-1">请选择</option>
								<option value="0">未审核</option>
								<option value="1">通过审核</option>
								<option value="1">未通过审核</option>
							</select>
						</div>
						<button onclick="selectinfo()" type="button"
							class="btn btn-primary">查询</button>
					</form>
				</div>

				<div class="force-overflow1-1">
					<table id="showtable"
						class="table table-condensed table-bordered table-hover"
						style="text-align: center">
						<tr style="background-color: #59c7d2">
						<tr style="background-color: #59c7d2">
							<th style="text-align: center">序号</th>
							<th style="text-align: center">商家名称</th>
							<th style="text-align: center">商品详情图</th>
							<th style="text-align: center">商品名称</th>
							<th style="text-align: center">商品类型</th>
							<th style="text-align: center">审核状态</th>
							<th style="text-align: center">查看详情</th>
							<th style="text-align: center">操作</th>
						</tr>
					</table>
					<div class="pageChange" style="margin-bottom:30px">
						<span onclick="prePage()">&nbsp;&nbsp;上一页&nbsp;&nbsp;</span> <span
							onclick="nextPage()">&nbsp;&nbsp;下一页&nbsp;&nbsp;</span> <em>
							&nbsp; 第&nbsp;<span id="pageNum">1</span>&nbsp;页&nbsp;&nbsp;
						</em> <em>/&nbsp;&nbsp;共&nbsp;<span id="totalpage"></span>&nbsp;页
						</em> <em>&nbsp;&nbsp;&nbsp;跳到第<input id="searchInput"
							style="width:46px" maxlength="4" type="text">页
						</em>
						<button class="btn btn-primary" onclick="searchPage()">搜索</button>
					</div>
				</div>
			</div>
		</section>
		<script>
			$(function() {
				selectinfo();
			})
			
		
			function selectinfo() {
				var pageNum = $("#pageNum").html();
				var pageCount = $("#pageCount").val();
				var productNames = $("#productNames").val();
				var status = $("#chakaVal").find("option:checked").val();
				if (!productNames) {
					productNames = null
				}
				if (status == -1) {
					status = null
				}
				$.post(urls + "directAction/getDirectProduct",
					{
						status : status,
						pageNum : pageNum,
						pageCount : pageCount,
						productName : productNames,
					},
					function(data) {
						//console.log(data)
						if (data) {
							var totalpage = data.totalpage;
							var orderlist = data.list;
							var table = $("#showtable");
							$("tr").remove(".addtr");
							for (var i = 0; i < orderlist.length; i++) {
								var hots = "";
								var status = "";
								var type = "";
								if (orderlist[i].type == 0) {
									type = "普通商品";
								} else if (orderlist[i].type == 1) {
									type = "推销商品";
								}
								if (orderlist[i].status == 0) {
									status = "未审核";
									hots = "未审核"
								} else if (orderlist[i].status == 1) {
									status = "审核通过";
									if (orderlist[i].putaway == 0) {
										hots = "<button class='btn btn-primary' onclick='isPutaway(\"" + orderlist[i].id + "\",1)'>点击上架</button>"
									} else if (orderlist[i].putaway == 1) {
										hots = "<button class='btn btn-primary' onclick='isPutaway(\"" + orderlist[i].id + "\",0)'>点击下架</button>"
									}
								} else if (orderlist[i].status == 2) {
									status = "未通过审核";
									hots = "审核失败"
								}
								var append = "<tr id='" + orderlist[i].id + "'  class='addtr'><td style='line-height:120px'>" + (i + 1) + "</td>" +
									"<td style='vertical-align:middle;'>" + orderlist[i].directName + "</td>" +
									"<td ><img style='width:250px;height:120px' src='/directs/" + orderlist[i].adImg + "' alt='加载中'/> </td>" +
									"<td style='vertical-align:middle;'>" + orderlist[i].productName + "</td>" +
									"<td style='vertical-align:middle;'>" + type + "</td>" +
									"<td style='vertical-align:middle;'>" + status + "</td>" +
									
									"<td style='line-height:120px'><input onclick='detailinfo(\"" +
									orderlist[i].thumbnailImg + "|$" +
									orderlist[i].adImg + "|$" +
									orderlist[i].detailsImg + "|$" +
									orderlist[i].banner.picture1 + "|$" +
									orderlist[i].banner.picture2 + "|$" +
									orderlist[i].banner.picture3 + "|$" +
									orderlist[i].productName + "|$" +
									orderlist[i].retailPrice + "|$" +
									orderlist[i].hotPrice + "|$" +
									orderlist[i].details + "|$" +
									orderlist[i].id + "|$" +
									orderlist[i].classify + "|$" +
									orderlist[i].type + "|$" +
									orderlist[i].specification + "|$" +
									orderlist[i].status + "|$" +
									orderlist[i].profit +
									"\")' type='button' class='btn btn-primary' value='查看详情' /></td>" +
									"<td style='line-height:120px'><input onclick='deletBurst(\"" + orderlist[i].id + "\")' type='button' class='btn btn-primary' value='删除' /></td></tr>";
								table.append(append);
							}
							$("#totalpage").html(totalpage);
						}
					}
					, "json"
				)
			}
			function deletBurst(e) { //删除爆款
				if (confirm("是够删除商品？")) {
					$.post(urls + "seckillAction/deleteSeckillOne",
						{
							id : e
						},
						function(res) {
							if (res) {
								$("#" + e).css("display", "none")
							} else {
								alert("删除商品失败")
							}
						})
				}
			}
			function detailinfo(e) { //点击修改
				var statusType;
				$("#directIds").val(localStorage.getItem("directid"))
				$("#motai").css("display", "block");
				$("#main").css("display", "none");
				var attr = e.split("|$");
				$("#image").attr("src", "/directs/" + attr[0]);
				$("#image2").attr("src", "/directs/" + attr[1]);
				$("#image3").attr("src", "/directs/" + attr[2]);
				$("#image4").attr("src", "/directs/" + attr[3]);
				$("#image5").attr("src", "/directs/" + attr[4]);
				$("#image6").attr("src", "/directs/" + attr[5]);
				$("#productName").val(attr[6]);
				$("#specification").val(attr[13]);
				$("#retailPrice").val(attr[7]);
				$("#hotPrice").val(attr[8]);
				$("#details").val(attr[9]);
				$("#ids").val(attr[10]);
				$("#classifyId").val(attr[11]);
				$("#types").val(attr[12]);
				$("#profit").val(attr[15]);
				if (attr[14] == 0) {
					statusType = "block";
				} else {
					statusType = "none"
				}
				$("#disbaled1").css("display", statusType)
				$("#disbaled2").css("display", statusType)
			}
		</script>
		<section id="motai" style="display:none">
			<div class="scrollbar1-1" id="style1-1">
				<div class="main_div" style="height: 560px;">
					<div class="main_title">
						<span>审核商品</span>
					</div>
					<form class="form-horizontal" enctype="multipart/form-data"
						style="margin-top: 30px" id="uploadForm">
						<input id="ids" name="id" style="display:none" /> <input
							value="0" name="status" style="display:none" /> <input
							id="directIds" name="directId" style="display:none" />
						<div class="form-group">
							<label class="col-xs-2 control-label">商品类型：</label>
							<div class="col-xs-3">
								<select id="classifyId" class="form-control" name="classify">
									<option value="-1">请选择</option>
									<option value="1">地方特色</option>
									<option value="2">手机电器</option>
									<option value="3">精品生活</option>
								</select>
							</div>
						</div>
						<div class="form-group">
							<label class="col-xs-2 control-label">商品是否推销：</label>
							<div class="col-xs-3">
								<select id="types" class="form-control" name="type">
									<option value="-1">请选择</option>
									<option value="0">普通商品</option>
									<option value="1">推销商品</option>
								</select>
							</div>
						</div>
						<div class="form-group">
							<label class="col-xs-2 control-label">商品名称：</label>
							<div class="col-xs-3">
								<input type="text" class="form-control" id="productName"
									name="productName" placeholder="商品名称">
							</div>
						</div>
						<div class="form-group">
							<label class="col-xs-2 control-label">商品规格：</label>
							<div class="col-xs-3">
								<input type="text" class="form-control" id="specification"
									name="specification" placeholder="商品规格">
							</div>
						</div>
						<div class="form-group">
							<label class="col-xs-2 control-label">原价：</label>
							<div class="col-xs-3">
								<input type="text" class="form-control" id="retailPrice"
									name="retailPrice" placeholder="请输入商品原价">
							</div>
						</div>
						<div class="form-group">
							<label class="col-xs-2 control-label">推销价：</label>
							<div class="col-xs-3">
								<input type="text" class="form-control" id="hotPrice"
									maxlength="6" name="hotPrice" placeholder="请输入商品推销价">
							</div>
						</div>
						<div class="form-group">
							<label class="col-xs-2 control-label">平台分润比例：</label>
							<div class="col-xs-3">
								<input type="text" class="form-control" id="profit"
									maxlength="6" name="profit" placeholder="请输入平台分润比例">
							</div>
							<label class="col-xs-5 control-label"
								style="text-align: left;color: #ff6c29">%</label>
						</div>
						<div class="form-group">
							<label class="col-xs-2 control-label">商品略缩图：</label>
							<div class="col-xs-3">
								<input type="file" id="thumbnailFile" name="thumbnailFile"
									onchange="selectImage(this);" /> <img id="image"
									style="width:125px;height:95px" src="" />
							</div>
							<label class="col-xs-5 control-label"
								style="text-align: left;color: #ff6c29">*必须上传略缩图（建议大小为125px*95px像素）</label>
						</div>
						<div class="form-group">
							<label class="col-xs-2 control-label">商品广告图：</label>
							<div class="col-xs-3">
								<input type="file" id="adFile" name="adFile"
									onchange="selectImage2(this);"> <img id="image2"
									style="width:375px;height:150px" src="" />
							</div>
							<label class="col-xs-5 control-label"
								style="text-align: left;color: #ff6c29">*必须上传商品banner图片（建议大小为375*150像素）</label>
						</div>
						<div class="form-group">
							<label class="col-xs-2 control-label">商品详情图片：</label>
							<div class="col-xs-3">
								<input type="file" id="detailsFile" name="detailsFile"
									onchange="selectImage3(this);"> <img id="image3"
									style="width:345px;" src="" />
							</div>
							<label class="col-xs-5 control-label"
								style="text-align: left;color: #ff6c29">*必须上传商品详情图片（建议宽度大小为345像素）</label>
						</div>
						<div class="form-group">
							<label class="col-xs-2 control-label">商品介绍图1：</label>
							<div class="col-xs-3">
								<input type="file" id="introduce1File" name="introduce1File"
									onchange="selectImage4(this);"> <img id="image4"
									style="width:375px;height:300px" src="" />
							</div>
							<label class="col-xs-5 control-label"
								style="text-align: left;color: #ff6c29">*必须上传商品详情图片（建议图片大小为375*300像素）</label>
						</div>
						<div class="form-group">
							<label class="col-xs-2 control-label">商品介绍图2：</label>
							<div class="col-xs-3">
								<input type="file" id="introduce2File" name="introduce2File"
									onchange="selectImage5(this);"> <img id="image5"
									style="width:375px;height:300px" src="" />
							</div>
							<label class="col-xs-5 control-label"
								style="text-align: left;color: #ff6c29">*必须上传商品详情图片（建议图片大小为375*300像素）</label>
						</div>
						<div class="form-group">
							<label class="col-xs-2 control-label">商品介绍图3：</label>
							<div class="col-xs-3">
								<input type="file" id="introduce3File" name=introduce3File
									onchange="selectImage6(this);"> <img id="image6"
									style="width:375px;height:300px" src="" />
							</div>
							<label class="col-xs-5 control-label"
								style="text-align: left;color: #ff6c29">*必须上传商品详情图片（建议图片大小为375*300像素）</label>
						</div>
						<div class="form-group">
							<label class="col-xs-2 control-label">商品简介：</label>
							<div class="col-xs-4">
								<textarea class="col-xs-12" rows="5" id="details" name="details"></textarea>
							</div>

						</div>
						<div class="col-xs-2 col-xs-offset-2">
							<button id="disbaled1" onclick="dealwithAD(1)"
								class="col-xs-8 btn btn-success" type="button">通过审核</button>
						</div>
						<div class="col-xs-2">
							<button id="disbaled2" onclick="dealwithAD(2)"
								class="col-xs-8 btn btn-info" type="button">不通过审核</button>
						</div>
					</form>
				</div>
			</div>
		</section>
	</div>
	<script>
		function dealwithAD(type) { //审核
			$.post(urls + "directAction/checkDirectProduct",
				{
					id : $("#ids").val(),
					status : type
				},
				function(res) {
					//console.log(res)
					if (res == true) {
						selectinfo();
						$("#motai").css("display", "none");
						$("#main").css("display", "block");
					}
				})
		}
		function deletBurst(id) { //删除
			$.post(urls + "directAction/checkDirectProduct",
				{
					id : id,
					status : -1
				},
				function(res) {
					//console.log(res)
					if (res == true) {
						selectinfo();
					}
				})
		}
	</script>
</body>
</html>
